package controller

import (
	"day01/project_learning/chapter_02/model"
	"fmt"
	"html/template"
	"net/http"
	"strconv"
)

type UserController struct {
}

func (c UserController) GetUser(w http.ResponseWriter, r *http.Request) {
	query := r.URL.Query()
	uid, _ := strconv.Atoi(query["uid"][0])

	user := model.GetUser(uid)
	fmt.Println(user)

	t, err := template.ParseFiles("D:\\project-web-go\\project-hello\\project_learning\\chapter_02\\template\\t3.html")
	//t, err := template.ParseFiles("..\\template\\t3.html")
	if err != nil {
		fmt.Println("文件读取失败")
	}
	userInfo := []string{user.Name, user.Phone}
	t.Execute(w, userInfo)
}
